////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  camxsensordriver.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "camxsensordriver.h"
#include "parametersetmanager.h"

CAMX_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SensorDriverDataClass::SensorDriverDataClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(slaveInfo);
    PARAMETER_INITIALIZE(regAddrInfo);
    PARAMETER_INITIALIZE(resolutionInfoCount);
    PARAMETER_INITIALIZE(resolutionInfoID);
    PARAMETER_INITIALIZE(resolutionInfo);
    PARAMETER_INITIALIZE(exposureControlInfo);
    PARAMETER_INITIALIZE(streamOnSettings);
    PARAMETER_INITIALIZE(streamOffSettings);
    PARAMETER_INITIALIZE(groupHoldOnSettings);
    PARAMETER_INITIALIZE(groupHoldOffSettings);
    PARAMETER_INITIALIZE(masterSettingsExists);
    PARAMETER_INITIALIZE(masterSettingsID);
    PARAMETER_INITIALIZE(masterSettings);
    PARAMETER_INITIALIZE(slaveSettingsExists);
    PARAMETER_INITIALIZE(slaveSettingsID);
    PARAMETER_INITIALIZE(slaveSettings);
    PARAMETER_INITIALIZE(initSettingsCount);
    PARAMETER_INITIALIZE(initSettingsID);
    PARAMETER_INITIALIZE(initSettings);
    PARAMETER_INITIALIZE(testPatternInfo);
    PARAMETER_INITIALIZE(colorLevelInfo);
    PARAMETER_INITIALIZE(opticalBlackRegionInfo);
    PARAMETER_INITIALIZE(pixelArrayInfo);
    PARAMETER_INITIALIZE(delayInfo);
    PARAMETER_INITIALIZE(sensorProperty);
    PARAMETER_INITIALIZE(noiseCoefficentExists);
    PARAMETER_INITIALIZE(noiseCoefficentID);
    PARAMETER_INITIALIZE(noiseCoefficent);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SensorDriverDataClass::SensorDriverDataClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(slaveInfo);
    PARAMETER_INITIALIZE(regAddrInfo);
    PARAMETER_INITIALIZE(resolutionInfo);
    PARAMETER_INITIALIZE(exposureControlInfo);
    PARAMETER_INITIALIZE(streamOnSettings);
    PARAMETER_INITIALIZE(streamOffSettings);
    PARAMETER_INITIALIZE(groupHoldOnSettings);
    PARAMETER_INITIALIZE(groupHoldOffSettings);
    PARAMETER_INITIALIZE(masterSettings);
    PARAMETER_INITIALIZE(slaveSettings);
    PARAMETER_INITIALIZE(initSettings);
    PARAMETER_INITIALIZE(testPatternInfo);
    PARAMETER_INITIALIZE(colorLevelInfo);
    PARAMETER_INITIALIZE(opticalBlackRegionInfo);
    PARAMETER_INITIALIZE(pixelArrayInfo);
    PARAMETER_INITIALIZE(delayInfo);
    PARAMETER_INITIALIZE(sensorProperty);
    PARAMETER_INITIALIZE(noiseCoefficent);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SensorDriverDataClass::~SensorDriverDataClass()
{
    UnloadSensorDriverData(this);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* SensorDriverDataClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "sensorDriverData")) == 0)
    {
        name = "sensorDriverData";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load SlaveInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadSlaveInformation(
    ParameterFileSymbolTableEntry* entry,
    SlaveInformation* structure)
{
    BOOL result = TRUE;

    // Reading structure->sensorName from the symbol table
    {
        UINT32 sensorNameCount = 0;
        result = result && entry->ReadUInt32(&sensorNameCount);
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        structure->sensorName = NULL;
        if (result)
        {
            pointerEntry1->ReadString(&structure->sensorName, sensorNameCount);
        }
    }
    result = result && entry->ReadUInt32(&structure->slaveAddress);
    result = result && entry->ReadUInt32(&structure->regAddrType);
    result = result && entry->ReadUInt32(&structure->regDataType);
    result = result && entry->ReadUInt32(&structure->sensorIdRegAddr);
    result = result && entry->ReadUInt32(&structure->sensorId);
    result = result && entry->ReadUInt32(&structure->sensorIdMask);
    structure->i2cFrequencyMode = (I2CFrequencyMode)entry->ReadEnum(&result);
    result = result && camxsensorcommonClass::LoadPowerSequenceInfo(entry, &structure->powerUpSequence);
    result = result && camxsensorcommonClass::LoadPowerSequenceInfo(entry, &structure->powerDownSequence);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load RegAddrInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadRegAddrInformation(
    ParameterFileSymbolTableEntry* entry,
    RegAddrInformation* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->xOutput);
    result = result && entry->ReadUInt32(&structure->yOutput);
    result = result && entry->ReadUInt32(&structure->frameLengthLines);
    result = result && entry->ReadUInt32(&structure->lineLengthPixelClock);
    result = result && entry->ReadUInt32(&structure->coarseIntgTimeAddr);

    // Reading structure->shortCoarseIntgTimeAddr from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->shortCoarseIntgTimeAddrExists);
        structure->shortCoarseIntgTimeAddrID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->shortCoarseIntgTimeAddrExists)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->shortCoarseIntgTimeAddr);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->shortCoarseIntgTimeAddr);
        }
    }
    result = result && entry->ReadUInt32(&structure->globalGainAddr);

    // Reading structure->shortGlobalGainAddr from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->shortGlobalGainAddrExists);
        structure->shortGlobalGainAddrID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->shortGlobalGainAddrExists)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->shortGlobalGainAddr);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->shortGlobalGainAddr);
        }
    }

    // Reading structure->digitalGlobalGainAddr from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->digitalGlobalGainAddrExists);
        structure->digitalGlobalGainAddrID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->digitalGlobalGainAddrExists)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->digitalGlobalGainAddr);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->digitalGlobalGainAddr);
        }
    }

    // Reading structure->digitalGainRedAddr from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->digitalGainRedAddrExists);
        structure->digitalGainRedAddrID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->digitalGainRedAddrExists)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->digitalGainRedAddr);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->digitalGainRedAddr);
        }
    }

    // Reading structure->digitalGainGreenRedAddr from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->digitalGainGreenRedAddrExists);
        structure->digitalGainGreenRedAddrID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->digitalGainGreenRedAddrExists)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->digitalGainGreenRedAddr);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->digitalGainGreenRedAddr);
        }
    }

    // Reading structure->digitalGainBlueAddr from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->digitalGainBlueAddrExists);
        structure->digitalGainBlueAddrID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->digitalGainBlueAddrExists)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->digitalGainBlueAddr);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->digitalGainBlueAddr);
        }
    }

    // Reading structure->digitalGainGreenBlueAddr from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->digitalGainGreenBlueAddrExists);
        structure->digitalGainGreenBlueAddrID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->digitalGainGreenBlueAddrExists)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->digitalGainGreenBlueAddr);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->digitalGainGreenBlueAddr);
        }
    }
    result = result && entry->ReadUInt32(&structure->testPatternRAddr);
    result = result && entry->ReadUInt32(&structure->testPatternGRAddr);
    result = result && entry->ReadUInt32(&structure->testPatternBAddr);
    result = result && entry->ReadUInt32(&structure->testPatternGBAddr);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load IntegrationInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadIntegrationInfo(
    ParameterFileSymbolTableEntry* entry,
    IntegrationInfo* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->integrationTimeMin);
    result = result && entry->ReadUInt32(&structure->integrationTimeStep);
    result = result && entry->ReadUInt32(&structure->integrationTimeMargin);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load StreamConfiguration
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadStreamConfiguration(
    ParameterFileSymbolTableEntry* entry,
    StreamConfiguration* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->vc);
    result = result && entry->ReadUInt32(&structure->dt);
    result = result && camxsensorcommonClass::LoadFrameDimension(entry, &structure->frameDimension);
    result = result && entry->ReadUInt32(&structure->bitWidth);
    structure->type = (StreamType)entry->ReadEnum(&result);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load StreamInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadStreamInformation(
    ParameterFileSymbolTableEntry* entry,
    StreamInformation* structure)
{
    BOOL result = TRUE;

    // Reading structure->streamConfiguration from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->streamConfigurationCount);
        structure->streamConfigurationID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->streamConfiguration   = PARAMETER_NEW StreamConfiguration[structure->streamConfigurationCount];
        }
        if (!result || structure->streamConfiguration == NULL)
        {
            structure->streamConfigurationCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->streamConfigurationCount; i++)
        {
            result = result && LoadStreamConfiguration(pointerEntry1, &structure->streamConfiguration[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load BorderInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadBorderInformation(
    ParameterFileSymbolTableEntry* entry,
    BorderInformation* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->left);
    result = result && entry->ReadUInt32(&structure->right);
    result = result && entry->ReadUInt32(&structure->top);
    result = result && entry->ReadUInt32(&structure->bottom);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ZZHDRInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadZZHDRInformation(
    ParameterFileSymbolTableEntry* entry,
    ZZHDRInformation* structure)
{
    BOOL result = TRUE;

    // Reading structure->ZZHDRPattern from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->ZZHDRPatternExists);
        structure->ZZHDRPatternID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->ZZHDRPatternExists)
        {
            structure->ZZHDRPattern = (ZZHDRColorPattern)pointerEntry1->ReadEnum(&result);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->ZZHDRPattern);
        }
    }

    // Reading structure->ZZHDRFirstExposure from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->ZZHDRFirstExposureExists);
        structure->ZZHDRFirstExposureID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->ZZHDRFirstExposureExists)
        {
            structure->ZZHDRFirstExposure = (ZZHDRFirstExposurePattern)pointerEntry1->ReadEnum(&result);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->ZZHDRFirstExposure);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ResolutionData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadResolutionData(
    ParameterFileSymbolTableEntry* entry,
    ResolutionData* structure)
{
    BOOL result = TRUE;
    structure->colorFilterArrangement = (ColorFilterArrangement)entry->ReadEnum(&result);
    result = result && LoadStreamInformation(entry, &structure->streamInfo);
    result = result && entry->ReadUInt32(&structure->lineLengthPixelClock);
    result = result && entry->ReadUInt32(&structure->frameLengthLines);
    result = result && entry->ReadUInt32(&structure->minHorizontalBlanking);
    result = result && entry->ReadUInt32(&structure->minVerticalBlanking);
    result = result && entry->ReadUInt32(&structure->outputPixelClock);
    result = result && entry->ReadUInt32(&structure->horizontalBinning);
    result = result && entry->ReadUInt32(&structure->verticalBinning);
    result = result && entry->ReadDouble(&structure->frameRate);
    result = result && entry->ReadUInt32(&structure->laneCount);

    // Reading structure->downScaleFactor from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->downScaleFactorExists);
        structure->downScaleFactorID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->downScaleFactorExists)
        {
            result = result && pointerEntry1->ReadFloat(&structure->downScaleFactor);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->downScaleFactor);
        }
    }
    result = result && entry->ReadUInt32(&structure->settleTimeNs);
    result = result && entry->ReadUInt32(&structure->is3Phase);

    // Reading structure->integrationInfo from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->integrationInfoExists);
        structure->integrationInfoID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->integrationInfoExists)
        {
            result = result && LoadIntegrationInfo(pointerEntry1, &structure->integrationInfo);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->integrationInfo);
        }
    }
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->resSettings);
    result = result && LoadBorderInformation(entry, &structure->cropInfo);

    // Reading structure->ZZHDRInfo from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->ZZHDRInfoExists);
        structure->ZZHDRInfoID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->ZZHDRInfoExists)
        {
            result = result && LoadZZHDRInformation(pointerEntry1, &structure->ZZHDRInfo);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->ZZHDRInfo);
        }
    }

    // Reading structure->capability from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->capabilityCount);
        structure->capabilityID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->capability   = PARAMETER_NEW SensorCapability[structure->capabilityCount];
            result = result && structure->capability != NULL;
        }
        if (!result || structure->capability == NULL)
        {
            structure->capabilityCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->capabilityCount; i++)
        {
            structure->capability[i] = (SensorCapability)pointerEntry1->ReadEnum(&result);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ResolutionInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadResolutionInformation(
    ParameterFileSymbolTableEntry* entry,
    ResolutionInformation* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->sensorVersion);

    // Reading structure->resolutionData from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->resolutionDataCount);
        structure->resolutionDataID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->resolutionData   = PARAMETER_NEW ResolutionData[structure->resolutionDataCount];
        }
        if (!result || structure->resolutionData == NULL)
        {
            structure->resolutionDataCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->resolutionDataCount; i++)
        {
            result = result && LoadResolutionData(pointerEntry1, &structure->resolutionData[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load InitSettings
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadInitSettings(
    ParameterFileSymbolTableEntry* entry,
    InitSettings* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->sensorVersion);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->initSetting);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ExposureContorlInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadExposureContorlInformation(
    ParameterFileSymbolTableEntry* entry,
    ExposureContorlInformation* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadDouble(&structure->maxAnalogGain);
    result = result && entry->ReadDouble(&structure->maxDigitalGain);
    result = result && entry->ReadUInt32(&structure->verticalOffset);
    result = result && entry->ReadUInt32(&structure->maxLineCount);
    result = result && entry->ReadDouble(&structure->realToRegDigitalGainConversionFactor);

    // Reading structure->realToRegGain from the symbol table
    {
        UINT32 realToRegGainCount = 0;
        result = result && entry->ReadUInt32(&realToRegGainCount);
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        structure->realToRegGain = NULL;
        if (result)
        {
            pointerEntry1->ReadString(&structure->realToRegGain, realToRegGainCount);
        }
    }

    // Reading structure->regToRealGain from the symbol table
    {
        UINT32 regToRealGainCount = 0;
        result = result && entry->ReadUInt32(&regToRealGainCount);
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        structure->regToRealGain = NULL;
        if (result)
        {
            pointerEntry1->ReadString(&structure->regToRealGain, regToRealGainCount);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load TestPatternData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadTestPatternData(
    ParameterFileSymbolTableEntry* entry,
    TestPatternData* structure)
{
    BOOL result = TRUE;
    structure->mode = (TestPatternMode)entry->ReadEnum(&result);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->settings);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load TestPatternInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadTestPatternInformation(
    ParameterFileSymbolTableEntry* entry,
    TestPatternInformation* structure)
{
    BOOL result = TRUE;

    // Reading structure->testPatternData from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->testPatternDataCount);
        structure->testPatternDataID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->testPatternData   = PARAMETER_NEW TestPatternData[structure->testPatternDataCount];
        }
        if (!result || structure->testPatternData == NULL)
        {
            structure->testPatternDataCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->testPatternDataCount; i++)
        {
            result = result && LoadTestPatternData(pointerEntry1, &structure->testPatternData[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ColorLevelInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadColorLevelInformation(
    ParameterFileSymbolTableEntry* entry,
    ColorLevelInformation* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->whiteLevel);
    result = result && entry->ReadUInt32(&structure->rPedestal);
    result = result && entry->ReadUInt32(&structure->grPedestal);
    result = result && entry->ReadUInt32(&structure->bPedestal);
    result = result && entry->ReadUInt32(&structure->gbPedestal);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load OpticalBlackRegionInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadOpticalBlackRegionInfo(
    ParameterFileSymbolTableEntry* entry,
    OpticalBlackRegionInfo* structure)
{
    BOOL result = TRUE;

    // Reading structure->dimension from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->dimensionCount);
        structure->dimensionID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->dimension   = PARAMETER_NEW FrameDimension[structure->dimensionCount];
        }
        if (!result || structure->dimension == NULL)
        {
            structure->dimensionCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->dimensionCount; i++)
        {
            result = result && camxsensorcommonClass::LoadFrameDimension(pointerEntry1, &structure->dimension[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PixelArrayInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadPixelArrayInfo(
    ParameterFileSymbolTableEntry* entry,
    PixelArrayInfo* structure)
{
    BOOL result = TRUE;
    result = result && camxsensorcommonClass::LoadDimension(entry, &structure->activeDimension);
    result = result && LoadBorderInformation(entry, &structure->dummyInfo);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load DelayInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadDelayInfo(
    ParameterFileSymbolTableEntry* entry,
    DelayInfo* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->linecount);
    result = result && entry->ReadUInt32(&structure->gain);
    result = result && entry->ReadUInt32(&structure->maxPipeline);
    result = result && entry->ReadUInt32(&structure->frameSkip);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load SensorProperty
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadSensorProperty(
    ParameterFileSymbolTableEntry* entry,
    SensorProperty* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadDouble(&structure->pixelSize);
    result = result && entry->ReadDouble(&structure->cropFactor);
    structure->sensingMethod = (SensingMethod)entry->ReadEnum(&result);
    result = result && entry->ReadDouble(&structure->ADCReadoutTime);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load NoiseCoefficent
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadNoiseCoefficent(
    ParameterFileSymbolTableEntry* entry,
    NoiseCoefficent* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadDouble(&structure->gradient_S);
    result = result && entry->ReadDouble(&structure->offset_S);
    result = result && entry->ReadDouble(&structure->gradient_O);
    result = result && entry->ReadDouble(&structure->offset_O);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load SensorDriverData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::LoadSensorDriverData(
    ParameterFileSymbolTableEntry* entry,
    SensorDriverData* structure)
{
    BOOL result = TRUE;
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);
    result = result && LoadSlaveInformation(entry, &structure->slaveInfo);
    result = result && LoadRegAddrInformation(entry, &structure->regAddrInfo);

    // Reading structure->resolutionInfo from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->resolutionInfoCount);
        structure->resolutionInfoID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->resolutionInfo   = PARAMETER_NEW ResolutionInformation[structure->resolutionInfoCount];
        }
        if (!result || structure->resolutionInfo == NULL)
        {
            structure->resolutionInfoCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->resolutionInfoCount; i++)
        {
            result = result && LoadResolutionInformation(pointerEntry1, &structure->resolutionInfo[i]);
        }
    }
    result = result && LoadExposureContorlInformation(entry, &structure->exposureControlInfo);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->streamOnSettings);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->streamOffSettings);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->groupHoldOnSettings);
    result = result && camxsensorcommonClass::LoadSettingsInfo(entry, &structure->groupHoldOffSettings);

    // Reading structure->masterSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->masterSettingsExists);
        structure->masterSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->masterSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->masterSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->masterSettings);
        }
    }

    // Reading structure->slaveSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->slaveSettingsExists);
        structure->slaveSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->slaveSettingsExists)
        {
            result = result && camxsensorcommonClass::LoadSettingsInfo(pointerEntry1, &structure->slaveSettings);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->slaveSettings);
        }
    }

    // Reading structure->initSettings from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->initSettingsCount);
        structure->initSettingsID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->initSettings   = PARAMETER_NEW InitSettings[structure->initSettingsCount];
        }
        if (!result || structure->initSettings == NULL)
        {
            structure->initSettingsCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->initSettingsCount; i++)
        {
            result = result && LoadInitSettings(pointerEntry1, &structure->initSettings[i]);
        }
    }
    result = result && LoadTestPatternInformation(entry, &structure->testPatternInfo);
    result = result && LoadColorLevelInformation(entry, &structure->colorLevelInfo);
    result = result && LoadOpticalBlackRegionInfo(entry, &structure->opticalBlackRegionInfo);
    result = result && LoadPixelArrayInfo(entry, &structure->pixelArrayInfo);
    result = result && LoadDelayInfo(entry, &structure->delayInfo);
    result = result && LoadSensorProperty(entry, &structure->sensorProperty);

    // Reading structure->noiseCoefficent from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->noiseCoefficentExists);
        structure->noiseCoefficentID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result && structure->noiseCoefficentExists)
        {
            result = result && LoadNoiseCoefficent(pointerEntry1, &structure->noiseCoefficent);
        }
        else
        {
            PARAMETER_INITIALIZE(structure->noiseCoefficent);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SensorDriverDataClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    SensorDriverData::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);
    result = result && entry->ReadInt32(&structure->incr_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload SlaveInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadSlaveInformation(
    SlaveInformation* structure)
{
    PARAMETER_DELETE[] structure->sensorName;
    camxsensorcommonClass::UnloadPowerSequenceInfo(&structure->powerUpSequence);
    camxsensorcommonClass::UnloadPowerSequenceInfo(&structure->powerDownSequence);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload StreamInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadStreamInformation(
    StreamInformation* structure)
{
    PARAMETER_DELETE[] structure->streamConfiguration;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload ResolutionData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadResolutionData(
    ResolutionData* structure)
{
    UnloadStreamInformation(&structure->streamInfo);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->resSettings);
    PARAMETER_DELETE[] structure->capability;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload ResolutionInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadResolutionInformation(
    ResolutionInformation* structure)
{
    for (UINT32 i = 0; i < structure->resolutionDataCount; i++)
    {
        UnloadResolutionData(&structure->resolutionData[i]);
    }
    PARAMETER_DELETE[] structure->resolutionData;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload InitSettings
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadInitSettings(
    InitSettings* structure)
{
    camxsensorcommonClass::UnloadSettingsInfo(&structure->initSetting);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload ExposureContorlInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadExposureContorlInformation(
    ExposureContorlInformation* structure)
{
    PARAMETER_DELETE[] structure->realToRegGain;
    PARAMETER_DELETE[] structure->regToRealGain;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload TestPatternData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadTestPatternData(
    TestPatternData* structure)
{
    camxsensorcommonClass::UnloadSettingsInfo(&structure->settings);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload TestPatternInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadTestPatternInformation(
    TestPatternInformation* structure)
{
    for (UINT32 i = 0; i < structure->testPatternDataCount; i++)
    {
        UnloadTestPatternData(&structure->testPatternData[i]);
    }
    PARAMETER_DELETE[] structure->testPatternData;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload OpticalBlackRegionInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadOpticalBlackRegionInfo(
    OpticalBlackRegionInfo* structure)
{
    PARAMETER_DELETE[] structure->dimension;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload SensorDriverData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SensorDriverDataClass::UnloadSensorDriverData(
    SensorDriverData* structure)
{
    UnloadSlaveInformation(&structure->slaveInfo);
    for (UINT32 i = 0; i < structure->resolutionInfoCount; i++)
    {
        UnloadResolutionInformation(&structure->resolutionInfo[i]);
    }
    PARAMETER_DELETE[] structure->resolutionInfo;
    UnloadExposureContorlInformation(&structure->exposureControlInfo);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->streamOnSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->streamOffSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->groupHoldOnSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->groupHoldOffSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->masterSettings);
    camxsensorcommonClass::UnloadSettingsInfo(&structure->slaveSettings);
    for (UINT32 i = 0; i < structure->initSettingsCount; i++)
    {
        UnloadInitSettings(&structure->initSettings[i]);
    }
    PARAMETER_DELETE[] structure->initSettings;
    UnloadTestPatternInformation(&structure->testPatternInfo);
    UnloadOpticalBlackRegionInfo(&structure->opticalBlackRegionInfo);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* SensorDriverDataClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    SensorDriverDataClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW SensorDriverDataClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && LoadSensorDriverData(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


CAMX_NAMESPACE_END
